{include file="public/header" /}

<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>项目定制</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
    <form method="get" name="formSearch" id="formSearch">
        <div class="ds-search-form">
            <dl>
                <dt>商品名称：</dt>
                <dd><input type="text" value="{$Request.get.search_goods_name|default=''}" name="search_goods_name" id="search_goods_name" class="txt"></dd>
            </dl>
            <dl>
                <dt>供应商：</dt>
                <dd><input type="text" value="{$Request.get.store_name|default=''}" name="store_name" id="store_name" class="txt"></dd>
            </dl>
            <div class="btn_group">
            	<input type="hidden" value="{$project_id}" name="project_id">
                 <a href="javascript:document.formSearch.submit();" class="btn " title="{$Think.lang.ds_query}">{$Think.lang.ds_query}</a>

                  {if $search_goods_name != '' || $store_name != ''}
                 <a href="{:url('Goodproject/projec_goods',['project_id'=>$project_id])}" class="btn btn-default"
                   title="{$Think.lang.ds_cancel}">{$Think.lang.ds_cancel}</a>
                  {/if}
                   <a href="javascript:void(0);" onclick="
                   edit_band_goods({$project_id});" class="btn">导入商品</a>
            </div>
        </div>
        <input type="hidden" value="" name="export">
    </form>
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom">
            <h4 >{$Think.lang.ds_explanation}</h4>
            <span></span>
        </div>
        <ul>
            <li style="font-size:14px;">当前项目定制标题为：{$title}</li>
        </ul>
    </div>
    <table class="ds-default-table">
        <thead>
            <tr>
                
                <th class="w60 align-center">平台货号</th>
                <th>商品</th>
                <th class="w272 align-center">商品名称及规格值</th>
                <th class="w272 align-center">分类名称&品牌</th>
                <th class=" align-center">供应商</th>
                <th class="w172 align-center">数量</th>
                <th class="w200 align-center">{$Think.lang.ds_handle}</th>
            </tr>
        </thead>

        <tbody>
        	{notempty name="goods_list"}
            {foreach name="goods_list" item="type" key="k"}
            {if $type.goods_name != ''}
            <tr id="ds_row_{$type.goods_commonid}">
               <td>{$k+1}</td>
              <td class="w60 picture">
                <div class="size-56x56"><span class="thumb size-56x56"><i></i><img src="{:goods_thumb($type, 240)}"
                                                                                   onload="javascript:ResizeImage(this,56,56);"/></span>
                </div>
              </td>
                <td>{$type.goods_name}</td>
                <td>
                <p>{$type.class_name}</p>
                <p class="goods-brand">{$Think.lang.ds_brand}：{$type.brand_name}</p>
            </td>
            <td>{$type.store_name}</td>
                <td>{$type.num}</td>
                <td>
                    <a class="dsui-btn-edit" href="javascript:dsLayerOpen('{:url('Goodproject/num',['project_id'=>$project_id,'goods_id'=>$type.goods_commonid])}','编辑-{$type.goods_name}','500px','300px')"><i class="iconfont"></i>编辑数量</a>

                    <a href="javascript:dsLayerConfirm('{:url('Goodproject/goods_drop',['project_id'=>$project_id,'goods_id'=>$type.goods_commonid])}','{$Think.lang.ds_ensure_del}',{$project_id})" class="dsui-btn-del"><i class="iconfont"></i>{$Think.lang.ds_del}</a>
                </td>
            </tr>
            {/if}
            {/foreach}
             {/notempty}
        </tbody>
    </table>
    {foreach name="goods_list" item="type"}
    {if $type.goods_name != ''}
    {$show_page}
    {/if}
    {/foreach}
</div>
<script>

    
    //按钮先执行验证再提交表单
    $(function(){

        var textButton1="<input type='text' name='textfield' id='textfield1' class='type-file-text' /><input type='button' name='button' id='button1' value='' class='type-file-button' />"
        $(textButton1).insertBefore("#project_images");
        $("#project_images").change(function(){$("#textfield1").val($("#project_images").val());});
        jQuery.validator.addMethod("initial", function(value, element) {
            return /^[A-Za-z0-9]$/i.test(value);
        }, "");
        $("#brand_form").validate({
            errorPlacement: function(error, element){
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules : {
                brand_name : {
                    required : true,
                    remote   : {
                        url :"{:url('Brand/ajax','branch=check_brand_name')}",
                        type:'get',
                        data:{
                            brand_name : function(){
                                return $('#brand_name').val();
                            },
                            id  : '{$project_id}'
                        }
                    }
                },
                brand_initial : {
                    initial  : true
                },
                brand_sort : {
                    number   : true,
                    range : [0,255]
                }
            },
            messages : {
                brand_name : {
                    required : '{$Think.lang.brand_add_name_null}',
                    remote   : '{$Think.lang.brand_add_name_exists}'
                },
                brand_initial : {
                    initial : '{$Think.lang.brand_add_initial}'
                },
                brand_sort  : {
                    number   : '{$Think.lang.brand_add_sort_int}',
                    range : '{$Think.lang.class_sort_explain}'
                }
            }
        });
    });

    gcategoryInit('gcategory');

    function edit_band_goods(ids_str) {
      _uri = ADMINSITEURL+"/Goodproject/edit_band_goods?project_id=" + ids_str;
        dsLayerOpen(_uri,'导入商品','1000px','700px');
    }
                $(function () {
                $('a[dstype="batch"]').click(function () {
                    if ($('.checkitem:checked').length == 0) {    //没有选择
                        layer.alert('<?php echo \think\Lang::get('select_record_want_operate'); ?>');
                        return false;
                    }
                    var _items = '';
                    $('.checkitem:checked').each(function () {
                        _items += $(this).val() + ',';
                    });
                    _items = _items.substr(0, (_items.length - 1));

                    var data_str = '';
                    eval('data_str = ' + $(this).attr('data-param'));

                    if (data_str.sign == 'jingle') {
                        ajax_form('ajax_jingle', '<?php echo \think\Lang::get('advertising'); ?>', data_str.urls + '?commonid=' + _items + '&inajax=1', '480');
                    } else if (data_str.sign == 'plate') {
                        ajax_form('ajax_plate', '<?php echo \think\Lang::get('set_associated_layout'); ?>', data_str.urls + '?commonid=' + _items + '&inajax=1', '480');
                    }
                });
            });
                //查看详情
    function goods_setting_info(ids_str) {
      _uri = HOMESITEURL+"/Goodproject/detail?project_id=" + ids_str;
        dsLayerOpen(_uri,'查看详情','800px','600px');
    }
    /**
 * Layer 通用ifram弹出窗口
 */
function dsLayerOpen(url, title,width,height) {
    if (!width) width = '900px';
    if (!height) height = '500px';
    layer.open({
        type: 2,
        title: title,
        area: [width,height],
        fixed: false, //不固定
        maxmin: true,
        content: url
    });
}  
</script>